package com.qingguo

import org.apache.spark.{SparkConf, SparkContext}

object Demo1 {

  def main(args: Array[String]): Unit = {

    val conf = new SparkConf()

    conf.setAppName("Demo1")

    conf.setMaster("local")

    val sc = new SparkContext(conf)

    val score = sc.textFile("Spark/data/words.txt")

    //    score.foreach(println)

    val resultRDD = score
      .flatMap(_.split(","))
      .map((_,1))
      .reduceByKey(_+_)

    resultRDD.foreach(println)

  }

}
